

// import {composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk'
import {applyMiddleware,createStore} from 'redux'
// 1.引入saga
// import createSagaMiddleware from 'redux-saga';
import reducer from './reducers';

// import rootSaga from './saga'

// 中间为一个函数
// const sagaMiddleware = createSagaMiddleware()

const enhancer = applyMiddleware(thunk)
// let enhancer = applyMiddleware(sagaMiddleware)
// 利用compose把多个中间件组合成一个中间件s
// let enhancer = compose(composeWithDevTools(applyMiddleware(sagaMiddleware)),applyMiddleware(thunk))

// 创建store数据仓库，并使用中间件
const store = createStore(reducer,enhancer)
console.log('store',store);

// 4.引入并运行自定义Saga配置
// sagaMiddleware.run(rootSaga);
// 监听操作
store.subscribe(function(){
    // 这里的代码在State被修改后执行
    console.log('subscribe',store.getState())
})

// 操作获取
const data1 = store.getState();
console.log('data1=',data1);
// 修改操作
export default store;